package demo

import (
	"github.com/zachary/tbox/internal/svc"
	"github.com/zachary/tbox/internal/util"
	util2 "github.com/zachary/tbox/internal/web/util"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/rest/httpx"
	"net/http"
	"time"
)

func GetAuthRoutes(serverCtx *svc.ServiceContext) []rest.Route {
	return []rest.Route{
		{
			Method:  http.MethodGet,
			Path:    "/from/:name",
			Handler: DemoHandler(serverCtx),
		},
	}
}

func GetNoAuthRoutes(serverCtx *svc.ServiceContext) []rest.Route {
	return []rest.Route{
		{
			Method: http.MethodGet,
			Path:   "/",
			Handler: func(writer http.ResponseWriter, request *http.Request) {
				httpx.OkJson(writer, util2.Success("treasure-box "+util.FormatDateTime(time.Now())))
			},
		},
	}
}
